<template>
	<view class="wf-box" :style="{ paddingTop: totalheight }">
		<view class="head" :style="{ paddingTop: navBarHeight }">
			<view class="head-np">
				<view class="back" @click="back()">
					<image src="../../static/img/chat-09.png"></image>
				</view>
				<view class="title">提现记录</view>
				<view></view>
			</view>
		</view>
<!-- :style="{ paddingTop: navBarHeight }" -->
		<view class="main">
			<view class="item" v-for="item in list" @click="details(item)">
				<image v-if="item.status!=2&&item.status!=3" src="@/static/img/extractive.png" mode=""></image>
				<image v-else src="@/static/img/extractive_n.png" mode=""></image>
				<view>
					<view class="text_1" :class="item.status!=2&&item.status!=3?'':'col_9'">USDT提现</view>
					<view class="text_3" :class="item.status!=2&&item.status!=3?'':'col_9'">{{ handleState(item.status) }}</view>
					<view class="text_2">{{item.created}}</view>
				</view>
				<view>
					<view :class="item.status!=2&&item.status!=3?'':'col_9'">{{item.status!=2&&item.status!=3?'-':''}}{{item.amount}}USDT</view>
					<view v-if="item.status==0" class="btn" @click.stop="cancel(item.id)">取消</view>
				</view>
			</view>
			<view v-if="list.length<1" class="not">暂无数据~</view>
		</view>
		<uni-popup ref="popup" type="center">
			<view class="popup-box">
				<view class="popup-title">温馨提示</view>
				<view class="popup-sub">确认要取消当前提现吗？</view>
				<view class="popup-footer">
					<view class="cancle" @click="closePopup()">撤销</view>
					<view class="confim" @click="confim()">确定</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {wapplyRecord , fundRecord,cancelApply} from '@/api/api.js'
	import navBarMixin from '@/mixin/navBarMixin.js'
	export default {
		data() {
			return {
				page: 1,
				size: 10,
				tabIndex: 0,
				list: '',
				isAll: false,
				id: '',
			}
		},
		mixins: [navBarMixin],
		onLoad(option) {
			this.record()
		},
		methods: {
			confim() {
				cancelApply({applyId:this.id}).then(res=>{
					console.log(res);
					this.closePopup()
					if (res.code == 0) {
						uni.showToast({
							title: '取消成功!',
							icon: 'none',
							duration: 2000,
						})
						this.record()
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 3000,
						})
					}
				})
			},
			cancel(e) {
				this.id = e
				this.$refs.popup.open()
			},
			closePopup() {
				this.$refs.popup.close()
				this.password = ''
			},
			back() {
				uni.navigateBack()
			},
			record() {
				wapplyRecord({pageNum:this.page,pageSize:this.size}).then(res=>{
					console.log(res);
					if(res.code==0) {
						var info = this.list
						if (this.page == 1) {
							this.list = res.data.records
						} else {
							this.list = info.concat(res.data.records)
						}
						this.isAll = this.list.length <10 ? false : true
					}
				})
			},
			details(e) {
				uni.navigateTo({
					url:'/pages/me/extractiveDetails?info='+JSON.stringify(e)
				})
			},
			handleState(e) {
				const arr = ['待审核','提现成功','提现驳回','提现撤销']
				return arr[e]
			}
		},
		onReachBottom() {
			console.log(this.isAll);
			if (this.isAll) {
				this.page++;
				if (this.tabIndex) this.select()
				else this.info()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wf-box {
		overflow: hidden;

		.back {
			image {
				width: 20rpx;
				height: 37rpx;
			}
		}

		.head {
			position: fixed;
			top: 0;
			z-index: 333;
			width: 100%;
			background: #fff;

			.head-np {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 100%;
				height: 96rpx;
				padding: 0 30rpx;
				box-sizing: border-box;

				.title {
					font-size: 36rpx;
					font-weight: bold;
				}
			}
		}

		.main {
			// margin-top: 126rpx;
			margin-top: 30rpx;
			margin: 30rpx 30rpx 60rpx;
			padding: 0 30rpx 40rpx;
			background-color: white;
			border-radius: 10rpx;
			overflow: hidden;

			.item {
				// height: 150rpx;
				padding: 16rpx 0;
				display: flex;
				align-items: center;
				border-bottom: 1rpx solid #EEEEEE;

				image {
					width: 54rpx;
					height: 54rpx;
					margin-right: 20rpx;
				}

				>view {
					.text_1 {
						font-size: 30rpx;
						// color: #333333;
						line-height: 42rpx;
					}
					.text_2 {
						height: 42rpx;
						font-size: 26rpx !important;
						font-weight: 400 !important;
						color: #999999;
						line-height: 42rpx;
						margin-top: 4rpx;
					}
					.text_3 {
						font-size: 26rpx;
						// text-align: right;
						color: #3F93FF;
						margin-top: 8rpx;
						// margin-bottom: 16rpx;
					}
					.btn {
						background-color: #3F93FF;
						color: white;
						text-align: center;
						font-size: 26rpx;
						width: 100rpx;
						margin-left: auto;
						padding: 6rpx 0;
						border-radius: 24rpx;
						margin-top: 20rpx;
					}
					&:nth-of-type(1) {
						flex: 1;
					}

					&:nth-of-type(2) {
						font-weight: 500;
						font-size: 30rpx;
						color: #FF5B5B;
					}
				}
			}
		}
		.popup-box {
			width: 583rpx;
			height: 580rpx;
			border-radius: 20rpx;
			box-sizing: border-box;
			background: #fff;
			background: url('../../static/img/me-32.png') no-repeat;
			background-size: cover;
			overflow: hidden;
			.popup-title {
				font-size: 32rpx;
				color: #333;
				font-weight: bold;
				text-align: center;
				margin-top: 180rpx;
			}
			.popup-text {
				margin: 240rpx 40rpx 0;
				font-size: 28rpx;
			}
			.popup-sub {
				margin-top: 100rpx;
				color: #666;
				font-size: 28rpx;
				text-align: center;
			}
			.popup-footer {
				display: flex;
				justify-content: space-between;
				margin: 72rpx 52rpx 0;
				.cancle {
					width: 200rpx;
					line-height: 76rpx;
					text-align: center;
					border: 2rpx solid #3F93FF;
					border-radius: 40rpx;
					color: #3F93FF;
				}
				.confim {
					width: 200rpx;
					line-height: 76rpx;
					text-align: center;
					border-radius: 40rpx;
					background: #3F93FF;
					color: #fff;
				}
			}
			input{
				// width: 500rpx;
				margin: 40rpx 40rpx 0;
				padding: 0 30rpx;
				height: 84rpx;
				font-size: 28rpx;
				line-height: 84rpx;
				background: #F4F4F4;
				border-radius: 6rpx 6rpx 6rpx 6rpx;
			}
		}
	}
	.not {
		color: #999999;
		text-align: center;
		margin: 30rpx auto;
	}
	.col_9 {
		color: #999999 !important;
	}
</style>